home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / combodlg.zip / COMBODLG.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-27  |  2KB  |  101 lines

  1. {************************************************}
  2. { finished simple example                        }
  3. {************************************************}
  4.  
  5. program MyProgram;
  6.  
  7. uses WinTypes, WinProcs, OWindows, ODialogs;
  8. {$R ComboDlg}
  9.  
  10. const
  11.   cm_Dialog = 105;
  12.   id_ListBox = 101;
  13.  
  14. type
  15.   TMyApplication = object(TApplication)
  16.     procedure InitMainWindow; virtual;
  17.   end;
  18.  
  19.   PMyDialog =^TMyDialog;
  20.   TMyDialog = Object(TDlgWindow)
  21.       ListBox: PListBox;
  22.     Constructor Init(AParent: PWindowsObject; AName: PChar);
  23.     procedure SetUpWindow; virtual;
  24.     procedure Ok(var Msg: TMessage);
  25.       virtual id_First + idOk;
  26.   end;
  27.  
  28. type
  29.   PMyWindow = ^TMyWindow;
  30.   TMyWindow = object(TWindow)
  31.     constructor Init(AParent: PWindowsObject; AName: PChar);    
  32.     procedure CmDialog(var Msg: TMessage);
  33.       virtual cm_First + cm_Dialog;
  34.   end;
  35.  
  36. {--------------------------------------------------}
  37. { TMyWindow's method implementations:              }
  38. {--------------------------------------------------}
  39.  
  40. constructor TMyDialog.Init(AParent: PWindowsObject; AName: PChar);
  41. begin
  42.   TDlgWindow.Init(AParent, AName);
  43.   ListBox := New(PComboBox, InitResource(@Self, Id_ListBox, 200));
  44. end;
  45.  
  46. procedure TMyDialog.SetUpWindow;
  47. var
  48.   S: array[0..200] of Char;
  49.   i: Integer;
  50. begin
  51.   TDlgWindow.SetUpWindow;
  52.   for i := 0 to 20 do begin
  53.     WvsPrintF(S, 'Item: %d', i);
  54.     ListBox^.AddString(S);
  55.   end;
  56. end;
  57.  
  58. procedure TMyDialog.Ok(var Msg: TMessage);
  59. begin
  60.   TDialog.Ok(Msg);
  61. end;
  62.  
  63. constructor TMyWindow.Init(AParent: PWindowsObject; AName: PChar);
  64. begin
  65.   TWindow.Init(AParent, AName);
  66.   Attr.Menu := LoadMenu(HInstance, 'Menu_1');
  67. end;
  68.  
  69. procedure TMyWindow.cmDialog(var Msg: TMessage);
  70. var
  71.   D: PMyDialog;
  72.  
  73. begin
  74.   D := new(PMyDialog, Init(@Self, 'Dialog_1'));
  75.   Application^.ExecDialog(D);
  76.   {ShowWindow(D^.HWindow, sw_Normal);}
  77. end;
  78.  
  79.  
  80. {--------------------------------------------------}
  81. { TMyApplication's method implementations:         }
  82. {--------------------------------------------------}
  83.  
  84. procedure TMyApplication.InitMainWindow;
  85. begin
  86.   MainWindow := New(PMyWindow, Init(nil, 'Sample ObjectWindows Program'));
  87. end;
  88.  
  89. {--------------------------------------------------}
  90. { Main program:                                    }
  91. {--------------------------------------------------}
  92.  
  93. var
  94.   MyApp: TMyApplication;
  95.  
  96. begin
  97.   MyApp.Init('MyProgram');
  98.   MyApp.Run;
  99.   MyApp.Done;
  100. end.
  101.